#include <iostream> 
using namespace std;
int main()
{
	int a,b,c,t;
	int a2,b2,c2;
	char j1,j2,j3,j4;
	int swap_1(int,int,int);
	int swap_2(int,int,int);
	cin>>a>>b>>c;
	if (a<=100 && b<=100 && c<=100)
	{
		a2 = swap_2(a,b,c);
		c2 = swap_1(a,b,c);
		if ((a2==a && c2==c) || (a2==c && c2==a)) b2=b;
		else if ((a2==b && c2==c) || (a2==c && c2==b)) b2=a;
		else if ((a2==a && c2==b) || (a2==b && c2==a)) b2=c;
		scanf("%c%c%c%c", &j1,&j2,&j3,&j4);
		int i[3] = {j2,j3,j4};
		for (t=0;t<3;t++)
		{
			if (i[t]=='A') cout<<a2;
			else if (i[t]=='B') cout<<b2;
			else if (i[t]=='C') cout<<c2;
			cout<<' ';
		}
	}
	else cout<<"Error!"<<endl;
	return 0;
}

int swap_1(int a,int b,int c)
{
	int i,t,l[]={a,b,c};
	t = l[0];
	for (i=0;i<3;i++)
	{
		if (l[0]>l[i+1]) t = l[0];
		else if (l[i+1]>t) t = l[i+1]; 
	}
	return t;
}

int swap_2(int a,int b,int c)
{
	int i,t,l[]={a,b,c};
	t = l[0];
	for (i=0;i<3;i++)
	{
		if (l[0]<l[i+1]) t = l[0];
		else if (l[i+1]<t) t = l[i+1]; 
	}
	return t;
}
